Page({
  data: {
    clubs: [
      { 
        id: 1, 
        name: "吉他协会", 
        description: "与各路大佬‘弹琴说爱’", 
        image: "https://gitee.com/guo-weifanGGG/liushenwuzu/raw/master/Docs/images/club/guitar_club.jpg" 
      },
      { 
        id: 2, 
        name: "太极拳协会", 
        description: "习练武当赵堡太极", 
        image: "https://gitee.com/guo-weifanGGG/liushenwuzu/raw/master/Docs/images/club/taichi_club.jpg" 
      },
      { 
        id: 3, 
        name: "书画协会", 
        description: "写一手好字 携一缕墨香", 
        image: "https://gitee.com/guo-weifanGGG/liushenwuzu/raw/master/Docs/images/club/calligraphy_club.jpg" 
      },
      { 
        id: 4, 
        name: "舞协", 
        description: "金秋迎新 舞韵飞扬", 
        image: "https://gitee.com/guo-weifanGGG/liushenwuzu/raw/master/Docs/images/club/dance_club.png" 
      },
      { 
        id: 5, 
        name: "篆刻协会", 
        description: "切磋琢磨 精敲细打", 
        image: "https://gitee.com/guo-weifanGGG/liushenwuzu/raw/master/Docs/images/club/engraving_club.png" 
      },
    ],
    filteredClubs: [],
    searchText: "",
  },
  onLoad() {
    this.setData({ filteredClubs: this.data.clubs }); // 初始化显示全部社团
  },
  onSearchInput(e) {
    const searchText = e.detail.value.toLowerCase();
    const filteredClubs = this.data.clubs.filter(club =>
      club.name.toLowerCase().includes(searchText) || 
      club.description.toLowerCase().includes(searchText)
    );
    this.setData({ searchText, filteredClubs });
  },
});